package com.settlement.system.model.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.settlement.system.common.base.BaseEntity;
import com.settlement.system.common.enums.LogRecordEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
        import java.time.LocalDateTime;

/**
* <p>
* 日志记录表
* </p>
*
* @author huangrensen
* @since 2024-06-20
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SysLogRecord extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
    * ID
    */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;


    /**
    * 平台ID
    */
    private Long platformId;
    @TableField(exist = false)
    private String platformName;


    /**
    * 店铺ID
    */
    private Long storeId;
    @TableField(exist = false)
    private String storeName;


    /**
    * 单据类型
    */
    private String orderType;

    /**
     * 任务KEY
     */
    private String jobKey;

    /**
     * 登陆账号
     */
    private String userName;


    /**
    * 周期
    */
    private String period;


    /**
    * 开始执行时间
    */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;


    /**
    * 运行结果
    */
    private String result = LogRecordEnum.NOT_RUN.getLabel();


    /**
    * 下载文件名
    */
    private String fileName;

    /**
     * 运行时间
     */
    private String countTime = "-";


    /**
    * 备注
    */
    private String remark;

    /**
     * 是否发送过信息(0未发1已发)
     */
    private int send = 0;

    // 截取长度超出范围的字段
    public void cutString() {
        if (this.remark != null && this.remark.length() > 2000) {
            this.remark = this.remark.substring(0, 2000);
        }
    }

}
